import { defineStore } from "pinia"
import {reactive, ref} from "vue";


//路由标签页
// let activeRoute = {
//     path: '',
//     name: '',
// };
let visitedRoutes=reactive([]) ;

export const useRouteStore = defineStore('route', {
    // 推荐使用 完整类型推断的箭头函数
    state: () => {
        //删除标签页
        const deleteTAb = (tabName)=>{
            //获取要删除的路由下标
            let tabIndex = visitedRoutes.findIndex((val)=>{
                return val.name ==  tabName
            })
            if(tabIndex != -1){
                visitedRoutes.splice(tabIndex,1);
            }
        }
        return {
            visitedRoutes,
            deleteTAb
        }
    },
})
